package com.niguang.work.labour.api.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.niguang.work.labour.api.entity.TeamUser;
import com.niguang.work.labour.api.service.TeamUserService;
import com.niguang.work.labour.api.vo.TeamListVo;
import com.niguang.work.labour.common.constant.ResultCode;
import com.niguang.work.labour.common.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * <p>
 * 'work.v_personSite' is not BASE TABLE 前端控制器
 * </p>
 *
 * @author 83673
 * @since 2018-11-17
 */
@RestController
@RequestMapping("workTeamUser/")
public class TeamUserController {

    @Autowired
    private TeamUserService workTeamUserService;

    /**
     * 获取班组列表
     *
     * @param teamId
     * @param page
     * @return
     */
    @GetMapping("getTeamListUser")
    public Result getTeamListUser(@NotNull @RequestParam String teamId, Page<Map<String, Object>> page) {
        return workTeamUserService.getTeamListUser(page, teamId);
    }
    /**
     * 查询班组列表
     *
     * @param page
     * @return
     */
    @GetMapping("getTeamList")
    public Result getTeamList(Page<TeamListVo> page, @NotNull @RequestParam Long siteId) {
        return Result.build(ResultCode.SUCCESS, "班组列表查询成功！",
                workTeamUserService.getTeamList(page, siteId));
    }


    /**
     * 班组增加成功
     *
     * @param workTeamUser
     * @return
     */
    @PostMapping("addTeamUser")
    public Result addTeamUser(@Valid TeamUser workTeamUser) {
        return workTeamUserService.addTeamUser(workTeamUser);

    }

    /**
     * 删除班组长
     *
     * @param teamId
     * @return
     */
    @GetMapping("delTeamUser")
    public Result delTeamUser(@NotNull @RequestParam Long teamId) {
        return workTeamUserService.delTeamUser(teamId);
    }

    /**
     * 编辑班组
     *
     * @param workTeamUser
     * @return
     */
    @PostMapping("modifTeamUser")
    public Result modifTeamUser(@Valid TeamUser workTeamUser) {
        return workTeamUserService.modifTeamUser(workTeamUser);
    }
}

